<?php
/**
 * 加载静态资源(js,css)
 * @author liiudaiming
 * @version 2014.2.27
 *
 */
class Resource{
	/**
	 * css资源
	 * @var array
	 */
	protected static $_cssArray = array(
		'admin'=>'Public/Css/admin/admin.css?v=14.2.27',
		'black'=>'Public/Css/admin/black.css?v=14.2.27',
		'blue'=>'Public/Css/admin/blue.css?v=14.2.27',
		'green'=>'Public/Css/admin/green.css?v=14.2.27',
		'ztree'=>'Public/ztree/css/zTreeStyle/zTreeStyle.css?v=2014.2.28',
		'push'=>'Public/Css/push/push.css?v=14.3.27',
		'apps'=>'Public/Css/apps/apps.css?v=14.4.8',
		'swupload'=>'Public/SWFUpload/css/swfupload.css',
		'mi_base'=>'Public/Css/push/base.css',
		'mi_bs'=>'Public/Css/push/bs.min.css',
		'mi_datepicker'=>'Public/Css/push/datetimepicker.min.css',
		'mi_push'=>'Public/Css/push/mipush.css',
		'treetable'=>'Public/Css/admin/jquery.treeTable.css?v=14.12.15',
		'tableform'=>'Public/Css/admin/table_form.css?v=14.12.15',
	);
	/**
	 * js资源
	 * @var array
	 */
	protected static $_jsArray = array(
		'jquery'=>'Public/Js/jquery.js?v=1.7.1',
		'cookie'=>'Public/Js/cookie.js?v=14.2.27',
		'common'=>'Public/Js/js_common.js?v=14.2.27',
		'ztree'=>'Public/ztree/js/jquery.ztree.core.min.js?v=2014.2.28',
		'dialog'=>'Public/artDialog/jquery.artDialog.js?skin=default',
		'ajaxmsg'=>'Public/Js/global.js?v=14.2.28',
		'ckeditor'=>'Public/ckeditor/ckeditor.js',
		'ckfinder'=>'Public/ckfinder/ckfinder.js',
		'validate'=>'Public/Js/jquery.validate.min.js?v=1.11',
		'push'=>'Public/Js/push.js?v=2014.3.28',
		'sw_js'=>'Public/SWFUpload/js/swfupload.js',
		'sw_queue'=>'Public/SWFUpload/js/swfupload.queue.js',
		'sw_file'=>'Public/SWFUpload/js/fileprogress.js',
		'sw_handler'=>'Public/SWFUpload/js/handlers.js',
		'calendar'=>'Public/DatePicker/WdatePicker.js',
		'mi_datepicker'=>'Public/Js/datetimepicker.min.js',
		'mi_jquery'=>'Public/Js/jquery-1.8.3.js?v=1.8.3',
		'treetable'=>'Public/Js/jquery.treetable.js?v=14.12.15',
	);
	/**
	 * 加载资源
	 * @param string $static
	 * @param string $type
	 */
	public static function getStatic($static,$type='css'){
		$static_path = C('STATIC_PATH');
		$script = '';
		switch ($type){
			case 'js':
				if (is_array($static)){
					foreach ($static as $val){
						if (key_exists($val, self::$_jsArray)){
							$script .= '<script type="text/javascript" src="'.$static_path.'/'.self::$_jsArray[$val].'"></script>';
						}
					}
				}else{
					if (key_exists($static, self::$_jsArray)){
							$script = '<script type="text/javascript" src="'.$static_path.'/'.self::$_jsArray[$static].'"></script>';
						}
				}
			break;
			default:
				if (is_array($static)){
					foreach ($static as $val){
						if (key_exists($val, self::$_cssArray)){
							$script .= '<link rel="stylesheet" href="'.$static_path.'/'.self::$_cssArray[$val].'" type="text/css" />';
						}
					}
				}else{
					if (key_exists($static, self::$_cssArray)){
							$script = '<link rel="stylesheet" href="'.$static_path.'/'.self::$_cssArray[$static].'" type="text/css" />';
						}
				}
		}
		return $script;
	}
	
}